#ifdef a
#include<stdio.h>
int main()
{
    //m个人排队报数，从1报到n(n < m)
    int m, n, count;
    count = 1;
    int sz = 0;
    scanf("%d%d", &m, &n);
    int a[100] = { 0 };
    while (1) {
        sz = 0;
        for (int i = 0; i < m; i++) {
            if (a[i] != -1 && count == n) {
                a[i] = -1;
                count = 1;
            }
            if (a[i] != -1)
                count++;
        }

        for (int j = 0; j < m; j++) {
            if (a[j] == 0)
                sz++;
        }
        if (sz == 1)
            break;
    }
    for (int i = 0; i < m; i++) {
        if (a[i] == 0)
            printf("%d\n", i + 1);
    }
}
#endif
